package fun.xinnix.publish;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class Producer {
    @Resource
    RabbitTemplate rabbitTemplate;

    public void send(String queueName, String msg) {
        for (int i = 0; i < 50; i++) {
            rabbitTemplate.convertAndSend(queueName, msg + (i + 1));
            ThreadUtil.sleep(50);
        }
        log.info("发送成功");
    }
}
